<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="${mapperReference}">
    <resultMap id="BaseResultMap" type="${modelReference}">
        <#list columnList as data>
        <#if data.columnName=='ID' || data.columnName=='id'>
        <id column="ID" jdbcType="${data.columnType}" property="id"/>
        <#else>
        <result column="${data.columnName}" jdbcType="${data.columnType}" property="${data.varName}"/>
        </#if>
        </#list>
    </resultMap>

    <!--  字段列表  -->
    <sql id="base_column_list">
        <trim suffixOverrides=",">
            <#list columnList as data>
            ${data.columnName},
            </#list>
        </trim>
    </sql>

    <!--  批量新增  -->
    <#if databaseName == "MySQL">
    <insert id="batchInsert${tableInfo.className}" parameterType="java.util.List">
        INSERT INTO ${tableInfo.tableName}
        <trim prefix=" (" suffix=") " suffixOverrides=",">
            <trim suffixOverrides=",">
                <#list columnList as data>
                ${data.columnName}<#if data_has_next>,</#if>
                </#list>
            </trim>
        </trim>
        values
        <foreach collection="list" item="item" index="index" separator=",">
            <trim prefix=" (" suffix=") " suffixOverrides=",">
                <#list columnList as data>
                <#noparse>#{</#noparse>item.${data.varName}<#noparse>}</#noparse><#if data_has_next>,</#if>
                </#list>
            </trim>
        </foreach>
    </insert>
    <#elseif databaseName == "Oracle" || databaseName == "DM DBMS">
    <insert id="batchInsert${tableInfo.className}" parameterType="java.util.List">
        INSERT ALL
        <foreach collection="list" item="item" index="index">
            INTO ${tableInfo.tableName}
            <trim prefix=" (" suffix=") " suffixOverrides=",">
                <#list columnList as data>
                ${data.columnName}<#if data_has_next>,</#if>
                </#list>
            </trim>
            VALUES
            <trim prefix=" (" suffix=") " suffixOverrides=",">
                <#list columnList as data>
                <#noparse>#{</#noparse>item.${data.varName}<#noparse>}</#noparse><#if data_has_next>,</#if>
                </#list>
            </trim>
        </foreach>
        SELECT 1 FROM DUAL
    </insert>
    <#else>
    </#if>

</mapper>
